package com.weaver.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

import java.util.*;
import java.util.stream.Collectors;

@SpringBootApplication
public class GatewayApplication {

	public static void main(String[] args) {

		SpringApplication.run(GatewayApplication.class, args);
//
//		Thread thread=new Thread(()->{System.out.println();});
		/*int f = f((a, b) -> {
			return a + b;
		}); //lambda 定义接口实现.并传入f方法
		System.out.println(f);


		Car.create(Car::new);*/
	}

//参数为接口
	public static int f(VoidTest v) {
		int a=1;
		int b = 2;
		return v.add(a, b); //调用lambda传入接口实现的方法

	}
	public static int a() {
		return 1;
	}
	//定义接口
	interface VoidTest{
		public  int add(int a,int b);
	}


	@Bean
	public RouteLocator myRoutes(RouteLocatorBuilder builder) {
		return builder.routes()
				.route(p -> p
						.path("/get")
						.filters(f -> f.addRequestHeader("Hello", "World"))
						.uri("http://httpbin.org:80"))
				.build();
	}

}

